﻿
$(document).ready(function () {
    initInfo();//加载信息

});

//加载信息
var initInfo = function () {
    //依赖于/scripts/common/jquery.data.js
    //加载日期
    var t = mini.get("begin_time");
    var data = fnGetSingleData("v_t_employee_contract", "id='" + getPar("eid") + "'");
    //反序列化实体对象到表单
    if (data != null && typeof (data) != "undefined" && data.length > 0) {
        //变更职务时加载原编码、姓名、职务
        $("#code").html(data[0].code);
        $("#name").html(data[0].employeeName);
        //默认为当前员工的合同截止时间
        t.setValue(data[0].contractEndDate);
    }
};


var fnCustomSave = function () {
    //数据校验
    var form = new mini.Form("editForm1");
    form.validate();
    if (!form.isValid()) return;
 
    var form_data = form.getData();
    //拼结数据
    form_data.eid = getPar("eid");
    if (form_data.end_time == "")
        form_data.end_time = "9999-12-31";
    fnClone(form_data, instance);
    if (typeof (instance) != "undefined" && instance != null) {
        var json = mini.encode(instance);//序列化成JSON
        $.ajax({
            url: "/extendpage/action/datasave.aspx?entity=t_employee_contract&flag=1&action=insert",
            type: "post",
            data: { data: json },
            cache: false,
            success: function (text) {
                if (text == 1) {
                 
                    alert("数据保存成功!")
                    fnClose();
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert(jqXHR.responseText);
            }
        });
    }
}


















//alert("");
//debugger
//var grid = mini.get("datagrid1");
//var keyText = mini.get("keyText");
//grid.load({ condition: "dept_id='2724B9F0-3468-4BB2-B212-22385BA69C93'" });

//function onSearchClick(e) {
//    grid.load({
//        key: keyText.value
//    });
//}
//function onCloseClick(e) {
//    var lookup2 = mini.get("code");
//    lookup2.hidePopup();
//}
//function onClearClick(e) {
//    var lookup2 = mini.get("code");
//    lookup2.deselectAll();
//}